﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using WS.EKA.UI.Business;

namespace WS.EKA.Web.UI.Bussiness
{
    internal class BarFactory : ReportBase<List<BarReportEntity>>
    {
        public override string GetJsonString(object parameter)
        {
            var _parameter = parameter as ReportParameter<List<BarReportEntity>>;
            JArray array = new JArray();
            foreach (var item in _parameter.Data)
            {
                JArray j = new JArray();
                j.Add(item.Category);
                j.Add(item.Count);
                array.Add(j);
            }
            string str = JsonConvert.SerializeObject(array);
            str = "[" + str + "]";
            return str;

        }
        public override WebSocketClientType Key
        {
            get { return WebSocketClientType.SampleBar; }
        }
    }

    public class BarReportEntity
    {
        public string Category { get; set; }
        public int Count { get; set; }
    }
}